#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;


 // Definition for singly-linked list.
  struct ListNode {
      int val;
      ListNode *next;
      ListNode(int x) : val(x), next(NULL) {}
    };
 
class Solution {
public:
    ListNode* getKthFromEnd(ListNode* head, int k) {
        //先走k个
        int i= 1;
        ListNode* curr = head;
        while(i<=k){
            curr = curr->next;
            i=i+1;
        }
        while(curr!=NULL){
            curr = curr->next;
            head = head->next;
        }
        return head;

    }
};